package com.ant.storage.controller;


import com.ant.storage.common.ResultVo;
import com.ant.storage.dto.OrganicDto;
import com.ant.storage.handler.AntException;
import com.ant.storage.service.IOrganicService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hzd
 * @since 2025-10-31
 */
@Api(tags = "披露表一接口")
@RestController
@RequestMapping("/organic")
public class OrganicController {
    @Autowired
    IOrganicService organicService;

    @ApiOperation(value = "保存行业信息")
    @PostMapping("/save")
    public ResultVo save(@RequestBody OrganicDto dto)
    {
        return ResultVo.success("添加成功",organicService.saveOrganic(dto));
    }

    @ApiOperation(value = "获取通过企业id获取列表")
    @ApiImplicitParam(name = "id", value = "企业id", required = true,dataType = "Integer", paramType = "query")
    @GetMapping("/listById")
    public ResultVo listById(Integer id){
        if(id==null){
            throw new AntException("请输入企业id");
        }
        return ResultVo.success("ok",organicService.listById(id));
    }


}
